// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using System;
using ValidationAspects.Exceptions;
using ValidationAspects.Sdk;

namespace ValidationAspects.Factories
{
	public class MinimumLength : ValidatorFactoryBase<string>
	{
		public int Length { get; set; }

		#region Overrides of ValidatorFactoryBase<string>
		protected override Action<string, IValidationContext> ValidateAction
		{
			get { return (v, c) => { if (v != null && v.Length < Length) throw new ValidateMinimumLengthException(Length, v.Length); }; }
		}
		#endregion
	}
}